import Vue from 'vue';
import Router from 'vue-router';

Vue.use(Router);

const routes = [
  {
    path: '*',
    redirect: '/list'
  },
  {
    name: 'list',
    component: () => import('./view/parent/list'),
    meta: {
      title: '智慧评价-计划列表'
    }
  },
  {
    name: 'plan',
    component: () => import('./view/parent/plan'),
    meta: {
      title: '智慧评价-计划详情'
    }
  },
  {
    name: 'question',
    component: () => import('./view/parent/question'),
    meta: {
      title: '智慧评价-评价'
    }
  },
  {
    name: 'view',
    component: () => import('./view/parent/view'),
    meta: {
      title: '智慧评价-预览'
    }
  },
  {
    name: 'message',
    component: () => import('./view/parent/message'),
    meta: {
      title: '请假更改'
    }
  },
  {
    name: 'teacher',
    component: () => import('./view/teacher'),
    meta: {
      title: '请假'
    }
  },
  {
    name: 'tPlanStatistics',
    component: () => import('./view/teacher/echarts'),
    meta: {
      title: '统计详情'
    }
  },
  {
    name: 'tList',
    component: () => import('./view/teacher/list'),
    meta: {
      title: '智慧评价-计划列表'
    }
  },
  
  {
    name: 'allList',
    component: () => import('./view/teacher/alllist'),
    meta: {
      title: '智慧评价-计划列表'
    }
  },
  {
    name: 'tPlan',
    component: () => import('./view/teacher/plan'),
    meta: {
      title: '智慧评价-计划详情'
    }
  },
  {
    name: 'tQuestion',
    component: () => import('./view/teacher/question'),
    meta: {
      title: '智慧评价-评价'
    }
  },
  {
    name: 'classHome',
    component: () => import('./view/teacher/classHome'),
    meta: {
      title: '班级考勤统计'
    }
  }

];

// add route path
routes.forEach(route => {
  route.path = route.path || '/' + (route.name || '');
});

const router = new Router({ routes });

router.beforeEach((to, from, next) => {
  const title = to.meta && to.meta.title;
  if (title) {
    document.title = title;
  }
  next();
});

export {
  router
};
